class ProjectGroupController {
    
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete:'POST', save:'POST', update:'POST']

    def home = {}

    def list = {
	[ projectGroupList: ProjectGroup.listOrderByName( ) ]
	
        
    }

    def show = {
        def projectGroup = ProjectGroup.get( params.id )

        if(!projectGroup) {
            flash.message = "ProjectGroup not found with id ${params.id}"
            redirect(action:list)
        }
        else { return [ projectGroup : projectGroup ] }
    }

    def delete = {
        def projectGroup = ProjectGroup.get( params.id )
        if(projectGroup) {
            projectGroup.delete()
            flash.message = "ProjectGroup ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "ProjectGroup not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def projectGroup = ProjectGroup.get( params.id )

        if(!projectGroup) {
            flash.message = "ProjectGroup not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ projectGroup : projectGroup ]
        }
    }

    def update = {
        def projectGroup = ProjectGroup.get( params.id )
        if(projectGroup) {
            projectGroup.properties = params
            if(!projectGroup.hasErrors() && projectGroup.save()) {
                flash.message = "ProjectGroup ${params.id} updated"
                redirect(action:show,id:projectGroup.id)
            }
            else {
                render(view:'edit',model:[projectGroup:projectGroup])
            }
        }
        else {
            flash.message = "ProjectGroup not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def projectGroup = new ProjectGroup()
        projectGroup.properties = params
        return ['projectGroup':projectGroup]
    }

    def save = {
        def projectGroup = new ProjectGroup(params)
        if(!projectGroup.hasErrors() && projectGroup.save()) {
            flash.message = "ProjectGroup ${projectGroup.id} created"
            redirect(action:show,id:projectGroup.id)
        }
        else {
            render(view:'create',model:[projectGroup:projectGroup])
        }
    }
}
